#include "Sesssion.hpp"
#include "Http.hpp"
#include "TcpServer.hpp"
#include <memory>

void Usage(std::string proc)
{
    std::cerr << "Usage: " << proc << " localport" << std::endl;
}


int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(0);
    }
    EnableConsoleLogStrategy();
    // HTTP 协议
    std::unique_ptr<Http> http=std::make_unique<Http>();

    // 网络服务
    uint16_t serverport = std::stoi(argv[1]);
    std::unique_ptr<TcpServer> tsock = std::make_unique<TcpServer>(serverport,
        [&http](std::string &reqstr)->std::string{
            return http->HandlerRequst(reqstr);
    });
    tsock->Run();

    return 0;
}
